package xyz.coolcsm.security.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import xyz.coolcsm.security.entity.Blog;
import xyz.coolcsm.security.entity.Favorite;

import java.util.List;
/**
 * @author 什锦
 * @since 2021-06-1
 */
@Mapper
@Repository
public interface BlogMapper extends BaseMapper<Blog> {

    @Select("<script>"
            + "SELECT * FROM sys_blog WHERE id IN "
            + "<foreach item='item' index='index' collection='strList' open='(' separator=',' close=')'>"
            + "#{item.bid}"
            + "</foreach>"
            + "limit #{start},#{pageSize}"
            + "</script>")
    public List<Blog> getBlogList(@Param("strList") List<Favorite> strList,
                                  @Param("start") Integer start,@Param("pageSize") Integer pageSize);

    @Select("<script>"
            + "SELECT * FROM sys_blog WHERE id IN "
            + "<foreach item='item' index='index' collection='strList' open='(' separator=',' close=')'>"
            + "#{item.bid}"
            + "</foreach>"
            + "</script>")
    public List<Blog> getBlogTotal(@Param("strList") List<Favorite> strList);
}
